namespace Gko.Utils
{
	/// <summary>
	/// Provides methods for manipulating objects.
	/// </summary>
	public static class ObjectUtility
	{
		/// <summary>
		/// Gets the hash code for the specified object.
		/// </summary>
		/// <param name="obj">The object for which to get a hash code.</param>
		/// <returns>The hash code for the specified object, or zero if the object is null.</returns>
		public static int GetHashCode<T>(T obj)
		{
			return ReferenceEquals(obj, null) ? 0 : obj.GetHashCode();
		}

		/// <summary>
		/// Swaps two items.
		/// </summary>
		/// <typeparam name="T">Type of parameters</typeparam>
		/// <param name="first">First item</param>
		/// <param name="second">Sencond item</param>
		public static void Swap<T>(ref T first, ref T second)
		{
			var temp = first;
			first = second;
			second = temp;
		}
	}
}